<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>v-bind动态绑定class(数组语法)</title>
</head>

<body>
  <div id="app">
    <!-- 加上单引号当成字符串 -->
    <h2 class="title" :class="['active','line']">{{message}}</h2>
    <!-- 不加单引号被当成变量 -->
    <!-- 和普通的类不冲突，有三个类title、active、line -->
    <h2 class="title" :class="[active, line]">{{message}}</h2>

    <!-- 如果过于复杂，可以放在一个method或者computed中，getClasses是一个计算属性也可以是一个method -->
    <h2 class="title" :class="getClasses">{{message}}</h2>

  </div>
  <script src="../js/vue.js"></script>
  <script>
    const app = new Vue({
      el: "#app",
      data: {
        message: "你好啊",
        active: "aaa",
        line: 'bbb'
      },
      computed: {
        getClasses() {
          return [this.active, this.line]
        }
      },
      methods: {
        // getClasses() {
        //   return [this.active, this.line]
        // }
      },
    })
  </script>
</body>

</html>